window.addEventListener('load', function () {
    // 首页获取并显示登录页面数据start
    var personA = document.querySelector('.personA');
    // personA.addEventListener('mouseover', function () {
    //     personH.style.display = 'block';
    // });
    var dataU = localStorage.getItem('username');
    var datap = localStorage.getItem('password');
    if (dataU != '') {
        personA.innerHTML = '欢迎 ' + dataU + '！';
    } else {
        personA.innerHTML = '个人中心';
    }
    // 首页获取并显示数据end
    // 首页获取并显示个人中心页面数据start
    var qqi = document.querySelector('.qqi');
    var qqLogin = document.querySelector('.qqLogin');
    var dataCe = localStorage.getItem('uunam');
    if (dataCe != '') {
        qqLogin.innerHTML = dataCe;
    } else {
        qqLogin.innerHTML = 'qq_login';
    }
    // 首页获取并显示个人中心页面数据end

    // layui的上传图片start
    layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'https://httpbin.org/post' //改成您自己的上传接口
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }


        });
    });
    var layuiB = document.querySelector('.layui-btn');
    var layuiI = document.querySelector('.layui-upload-img');
    // alert(layuiI.src);
    window.location.href = 'index.html';
    window.location.href = 'setPerson.html';
    window.location.href = 'setName.html';
    window.location.href = 'setImg.html';
    window.location.href = 'Introduction.html';
    window.location.href = 'plan.html';
    window.location.href = 'list.html';
    // 修改qq图像start
    var imgS = localStorage.setItem('imgs',layuiI.src);
    qqi.src = imgS;    // 修改qq图像end
    // layui的上传图片end
})
